let activeIndex = 1; // 当前激活的卡片索引
const btns = document.querySelectorAll('.button');
const cards = document.querySelectorAll('.card'); // 提前获取所有卡片

btns.forEach(btn => {
    btn.addEventListener("click", () => {
        console.log('click', activeIndex);

        // 移除当前激活卡片的'active'类，并添加'inactive'类
        cards[activeIndex - 1].classList.remove('active');
        cards[activeIndex - 1].classList.add('inactive');

        // 更新激活卡片的索引
        activeIndex++;
        if (activeIndex > cards.length) {
            activeIndex = 1; // 如果超出卡片数量，重置为第一张
        }

        // 为新的激活卡片添加'active'类，并移除'inactive'类
        cards[activeIndex - 1].classList.remove('inactive');
        cards[activeIndex - 1].classList.add('active');
    });
});

